#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/2/16 17:46
# @Author  : ldh
from time import sleep

from basic.device.Android import Android


class awz_search_page(Android) :
    tvSearch = "cn.cloudbae.lovewuzhou:id/tvSearch"
    etSearch = "cn.cloudbae.lovewuzhou:id/etSearch"
    open_app = "cn.cloudbae.lovewuzhou:id/open_app"

    # 打开搜索页
    @classmethod
    def open_search(cls) :
        cls.poco(cls.tvSearch).click()

    @classmethod
    def check(cls) :
        if cls.poco(text = "热门搜索").exists() :
            return True
        else :
            return False

    @classmethod
    def moveout(cls) :
        cls.poco(text = "热门搜索").click()

    # 输入关键字进行搜索
    @classmethod
    def search(cls) :
        cls.poco(cls.etSearch).set_text("食堂云")
        sleep(3)

    @classmethod
    def ifempty(cls) :
        if cls.poco(cls.open_app).exists() :
            return True
        else :
            print("搜索结果为空！")
            return False

    # 查看搜索结果详情
    @classmethod
    def openapp(cls) :
        cls.poco(cls.open_app)[0].click()
        sleep(3)
